home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q37632 < prev    next >
Text File  |  1988-11-14  |  2KB  |  59 lines

  1. Q37632 /Au, /Aw Switches Fail in Medium-Memory Model
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.  
  8. The code fragment below demonstrates a problem with Microsoft C
  9. Version 5.10. The problem occurs when you desire SS!=DS in
  10. medium-memory model.
  11.  
  12. Microsoft has confirmed this to be a problem in Version 5.10. We are
  13. researching this problem and will post new information as it becomes
  14. available.
  15.  
  16.  
  17. More Information:
  18.  
  19. The following code fragment demonstrates the problem:
  20.  
  21.  /*inc(int far *);*/
  22.  main()
  23.  {
  24.     int p=666;
  25.     inc(&p);
  26.  }
  27.  inc(p)
  28.   int /*far*/ *p;
  29.   {
  30.      int *q;
  31.      *p+=1;
  32.   }
  33.  
  34. If you compile the above source code with the following command line
  35. options, you will expect the generated code to force DS != SS, as
  36. desired in most Windows programming:
  37.  
  38.  /AM /Au /c /Fc or
  39.  /AM /Aw /c /Fc
  40.  
  41. However, on inspecting the .cod file generated as a result of the /Fc
  42. switch, the assembly code generated fails to force the stack pointer
  43. sp to point at DS.
  44.  
  45. To work around this problem, note the commented out prototyping of the
  46. function inc() and the commented out cast of the pointer *p to far in
  47. the function inc(). Invoking this prototyping and casting code forces
  48. the compiler to generate the following lines, as can be observed from
  49. the corresponding .cod file:
  50.  
  51.  les     bx,DWORD PTR[bp+6]
  52.  inc     WORD PTR es:[bx].
  53.  
  54. This process uses the ES register, causing the proper code execution
  55. on a copy of DS held in ES.
  56.  
  57. Keywords:  buglist5.10
  58. Updated  88/11/15 06:14
  59.